//  实现打印当前目录树
const fs = require('fs');

function main(){
	readDir();
}

async function readDir(path,space){
	if(!path){
		path = "./";
	}
	if(!space){
		space = "|---"
	}
	let dirs = fs.readdirSync(path);
	for(let i=0;i<dirs.length;i++){
		try{
			if(path !== "./"){
				path += "/"
			}
			let files = fs.statSync((path + dirs[i]));
			console.log(space+dirs[i]);
			if(files.isDirectory()){
				let temp = path+""+dirs[i]
				readDir(temp,"   "+space);
				continue;
			}
		}catch(err){

		}
	}

}

main()
